#ifndef ESP12F_AT_H
#define ESP12F_AT_H

#include "main.h"

#define ESP_UART &huart2
#define ESP_ENABLE_GPIO_PORT GPIOA
#define ESP_ENABLE_GPIO_PIN GPIO_PIN_1
#define CMD_TIMEOUT 5000 // 命令超时(ms)
#define RX_BUFFER_SIZE 1024

typedef enum {
  ESP_OK,
  ESP_ERROR,
  ESP_TIMEOUT,
  ESP_CONNECT_FAIL
} ESP_Status;

// AT命令响应类型
typedef enum {
  AT_OK,
  AT_ERROR,
  AT_OTHER
} AT_ResponseType;

// 初始化函数
void ESP_Init(void);
ESP_Status ESP_ConnectWiFi(const char *ssid, const char *pass);
ESP_Status ESP_ConnectTCP(const char *ip, uint16_t port);
ESP_Status ESP_SendData(const uint8_t *data, uint16_t len);
void ESP_ProcessReceivedData(void);

// 回调函数原型
typedef void (*DataReceivedCallback)(uint8_t *data, uint16_t len);
void ESP_RegisterDataCallback(DataReceivedCallback callback);

#endif